home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Workbench / ToolManager / Source / Prefs / clipwindow.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  5KB  |  158 lines

  1. /*
  2.  * clipwindow.c  V3.1
  3.  *
  4.  * Class for TM objects clipboard window
  5.  *
  6.  * Copyright (C) 1990-98 Stefan Becker
  7.  *
  8.  * This source code is for educational purposes only. You may study it
  9.  * and copy ideas or algorithms from it for your own projects. It is
  10.  * not allowed to use any of the source codes (in full or in parts)
  11.  * in other programs. Especially it is not allowed to create variants
  12.  * of ToolManager or ToolManager-like programs from this source code.
  13.  *
  14.  */
  15.  
  16. #include "toolmanager.h"
  17.  
  18. /* Local data */
  19. static const char *TextTitle;
  20. static const char *HelpList;
  21.  
  22. /* ClipWindow class instance data */
  23. struct ClipWindowClassData {
  24.  ULONG cwcd_Dummy;
  25. };
  26. #define TYPED_INST_DATA(cl, o) ((struct ClipWindowClassData *) INST_DATA((cl), (o)))
  27.  
  28. /* ClipWindow class method: OM_NEW */
  29. #define DEBUGFUNCTION ClipWindowClassNew
  30. static ULONG ClipWindowClassNew(Class *cl, Object *obj, struct opSet *ops)
  31. {
  32.  Object *ListView;
  33.  Object *List;
  34.  Object *Delete;
  35.  
  36.  CLIPWINDOW_LOG((LOG1(Tags, "0x%08lx", ops->ops_AttrList),
  37.                  PrintTagList(ops->ops_AttrList)))
  38.  
  39.  /* Create object */
  40.  if (obj = (Object *) DoSuperNew(cl, obj,
  41.         MUIA_Window_Title,    TextTitle,
  42.         MUIA_Window_ID,       MAKE_ID('C','L','I','P'),
  43.         MUIA_Window_Activate, FALSE,
  44.         WindowContents,       VGroup,
  45.          Child, VGroup,
  46.           MUIA_Background,  MUII_GroupBack,
  47.           MUIA_Frame,       MUIV_Frame_Group,
  48.           MUIA_ShortHelp,   HelpList,
  49.           Child, ListView = ListviewObject,
  50.            MUIA_Listview_DragType, MUIV_Listview_DragType_Immediate,
  51.            MUIA_Listview_List, List = NewObject(ClipListClass->mcc_Class, NULL,
  52.             MUIA_Frame, MUIV_Frame_InputList,
  53.            End,
  54.            MUIA_CycleChain,        TRUE,
  55.           End,
  56.           Child, Delete = MakeButton(TextGlobalDelete, HelpGlobalDelete),
  57.          End,
  58.         End,
  59.         MUIA_HelpNode,        "ClipWindow",
  60.         TAG_MORE,             ops->ops_AttrList)) {
  61.  
  62.   /* Close window action */
  63.   DoMethod(obj,      MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  64.            MUIV_Notify_Application, 4, MUIM_Application_PushMethod,
  65.            obj, 2, TMM_Finish, TMV_Finish_Cancel);
  66.  
  67.   /* Double-Click action */
  68.   DoMethod(ListView, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE,
  69.            List, 1, TMM_DoubleClicked);
  70.  
  71.   /* Button actions */
  72.   DoMethod(Delete,   MUIM_Notify, MUIA_Pressed, FALSE,
  73.            List, 2, MUIM_List_Remove, MUIV_List_Remove_Active);
  74.  }
  75.  
  76.  CLIPWINDOW_LOG(LOG1(Result, "0x%08lx", obj))
  77.  
  78.  /* Return pointer to created object */
  79.  return((ULONG) obj);
  80. }
  81.  
  82. /* ClipWindow class method: TMM_Finish */
  83. #undef  DEBUGFUNCTION
  84. #define DEBUGFUNCTION ClipWindowClassFinish
  85. static ULONG ClipWindowClassFinish(Class *cl, Object *obj,
  86.                                    struct TMP_Finish *tmpf)
  87. {
  88.  CLIPWINDOW_LOG(LOG0(Entry))
  89.  
  90.  /* Close window */
  91.  SetAttrs(obj, MUIA_Window_Open, FALSE, TAG_DONE);
  92.  
  93.  /* Remove window from application */
  94.  DoMethod(_app(obj), OM_REMMEMBER, obj);
  95.  
  96.  /* Dispose object */
  97.  MUI_DisposeObject(obj);
  98.  
  99.  /* Return 1 to indicate that the method is implemented */
  100.  return(1);
  101. }
  102.  
  103. /* ClipWindow class method dispatcher */
  104. #undef  DEBUGFUNCTION
  105. #define DEBUGFUNCTION ClipWindowClassDispatcher
  106. __geta4 static ULONG ClipWindowClassDispatcher(__a0 Class *cl,
  107.                                                __a2 Object *obj,
  108.                                                __a1 Msg msg)
  109. {
  110.  ULONG rc;
  111.  
  112.  CLIPWINDOW_LOG(LOG3(Arguments, "Class 0x%08lx Object 0x%08lx Msg 0x%08lx",
  113.                      cl, obj, msg))
  114.  
  115.  switch(msg->MethodID) {
  116.   /* BOOPSI methods */
  117.   case OM_NEW:
  118.    rc = ClipWindowClassNew(cl, obj, (struct opSet *) msg);
  119.    break;
  120.  
  121.   /* TM methods */
  122.   case TMM_Finish:
  123.    rc = ClipWindowClassFinish(cl, obj, (struct TMP_Finish *) msg);
  124.    break;
  125.  
  126.   /* Unknown method -> delegate to SuperClass */
  127.   default:
  128.    rc = DoSuperMethodA(cl, obj, msg);
  129.    break;
  130.  }
  131.  
  132.  return(rc);
  133. }
  134.  
  135. /* Create ClipWindow class */
  136. #undef  DEBUGFUNCTION
  137. #define DEBUGFUNCTION CreateClipWindowClass
  138. struct MUI_CustomClass *CreateClipWindowClass(void)
  139. {
  140.  struct MUI_CustomClass *rc;
  141.  
  142.  /* Create class */
  143.  if (rc = MUI_CreateCustomClass(NULL, MUIC_Window, NULL,
  144.                                 sizeof(struct ClipWindowClassData),
  145.                                 ClipWindowClassDispatcher)) {
  146.  
  147.   /* Localize strings */
  148.   TextTitle = TranslateString(LOCALE_TEXT_CLIPWINDOW_TITLE_STR,
  149.                               LOCALE_TEXT_CLIPWINDOW_TITLE);
  150.   HelpList  = TranslateString(LOCALE_HELP_CLIPWINDOW_LIST_STR,
  151.                               LOCALE_HELP_CLIPWINDOW_LIST);
  152.  }
  153.  
  154.  CLIPWINDOW_LOG(LOG1(Result, "0x%08lx", rc))
  155.  
  156.  return(rc);
  157. }
  158.